package com.lianzhihui.romeex.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.ui.orepool.CommunityRuleActivity;

import org.bouncycastle.jcajce.provider.symmetric.TEA;

import java.util.List;

/**
 * Description: 主页适配器
 * Author: RAMON
 * CreateDate: 2020/11/4 8:10 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class RuleActivityAdapter extends BaseQuickAdapter<CommunityRuleActivity.RuleBean, BaseViewHolder> {

    Context mContext;
    int currentLevel;

    public RuleActivityAdapter(@Nullable Context mContext, @Nullable List<CommunityRuleActivity.RuleBean> data, int currentLevel) {
        super(R.layout.item_rule_layout, data);
        this.mContext = mContext;
        this.currentLevel = currentLevel;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CommunityRuleActivity.RuleBean item) {
        helper.setText(R.id.tv_level, "R" + item.getLevel())
                .setText(R.id.tv_condition, item.getCondition())
                .setText(R.id.tv_earnings, item.getEarnings());

        if (item.isIscheck()) {
            if (item.getLevel() != 5) {
                helper.getView(R.id.iv_up_grade).setVisibility(View.VISIBLE);
            }
            helper.getView(R.id.dis_layout).setBackgroundColor(mContext.getResources().getColor(R.color.text_24254B_color));
            TextView tvLevel = helper.getView(R.id.tv_level);
            tvLevel.setTextColor(mContext.getResources().getColor(R.color.white));
            TextView tvCondition = helper.getView(R.id.tv_condition);
            tvCondition.setTextColor(mContext.getResources().getColor(R.color.white));
            TextView tvEarnings = helper.getView(R.id.tv_earnings);
            tvEarnings.setTextColor(mContext.getResources().getColor(R.color.white));

        }

    }
}
